home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10667 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  909 b 

  1. Path: news2.noc.netcom.net!news
  2. Newsgroups: comp.lang.c
  3. Subject: Re: operator % - compiler error
  4. Message-ID: <314DD835.33BE@willows.com>
  5. From: Tarang Deshpande <tarang@willows.com>
  6. Date: Mon, 18 Mar 1996 13:40:05 -0800
  7. References: <4ihuuh$6ul@hatathli.csulb.edu>
  8. Organization: NETCOM Network Operations
  9. NNTP-Posting-Host: daffy.willows.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13.  
  14. David Cho wrote:
  15. > When I try to compile, I get an erro message for the following line:
  16. > x=663608941*y%pow(2,32)  /*I want remainder*/
  17. > But the error message says "illegal use of floating point".  What does
  18. > that mean?  Isn't % used a an operator to calcuate the remainder?
  19.  
  20. Although the % operator calculates the remainder it does so for two
  21. ints and not two floats or double.  You need to change your code to
  22.  
  23. x = ( long )( 663608941 * y ) % ( long )( pow ( 2, 32 ) );
  24.  
  25.